package com.xbongbong.parent.condition.impl;

import com.xbongbong.paas.enums.FieldTypeEnum;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.field.FilterConditionsPoJo;
import com.xbongbong.paas.field.LinkConditionPoJo;
import com.xbongbong.paas.field.LinkInfoPojo;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.parent.abstracts.AbstractConditionFieldHandler;
import com.xbongbong.pro.businessrule.pojo.BusinessRuleInfoPojo;
import com.xbongbong.pro.condition.pojo.ConditionDTO;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;

/**
 * 地址和定位处理
 * @author: xingxing.xiao
 * @date: 2020/08/18 16:34
 */
@Component
public class ConditionFormAddressHandlerImpl extends AbstractConditionFieldHandler {

    @Override
    public List<Integer> fieldType() {
        return Arrays.asList(FieldTypeEnum.ADDRESS.getType(), FieldTypeEnum.LOCATION.getType());
    }


    @Override
    public Object handlerRelyFormField(String corpid, FieldAttrEntity fieldAttrEntity, FieldAttrEntity relyFieldEntity, LinkConditionPoJo linkConditionPoJo, LinkInfoPojo linkInfoPojo, Object value) throws XbbException {
        return value;
    }

    @Override
    public Object handlerLinkDataFixedValue(String corpid, FieldAttrEntity relyFieldEntity, LinkInfoPojo linkInfoPojo, Object value) throws XbbException {
        return value;
    }

    @Override
    public Object handlerBusinessRelyFormField(String corpid, FieldAttrEntity fieldAttrEntity, FieldAttrEntity relyFieldEntity, LinkConditionPoJo linkConditionPoJo, Object value, Long linkFormId, Integer linkBusinessType, Integer linkSaasMark) throws XbbException {
        return value;
    }

    @Override
    public Object handlerBusinessDataFixedValue(String corpid, FieldAttrEntity relyFieldEntity, ConditionDTO conditionDTO, Object value) throws XbbException {
        return value;
    }

    @Override
    public Object handlerPreConditionValue(FieldAttrEntity thisField, BusinessRuleInfoPojo businessRuleInfoPojo, FilterConditionsPoJo filterCondition) throws XbbException {
        // 进入ConditionFormDefaultHandlerImpl中
        return filterCondition.getValue();
    }
}
